package com.lyn.plugin.utils;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author Lyn
 * @date 2022/5/22
 * @desc
 */
public class AdbUtl {

    /**
     * 获取CPU 架构
     * @return 架构名称
     */
    public static String getCPUAbi(){
        return execShell("getprop ro.product.cpu.abi");
    }

    public static String execShell(String cmd) {
        StringBuilder sb = new StringBuilder();
        try {
            Runtime runtime = Runtime.getRuntime();
            Process process = runtime.exec(cmd);
            InputStream inputStream = process.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            process.waitFor();
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                sb.append(line).append("\n");
            }
            inputStream.close();
            bufferedReader.close();
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
